﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tank
{
    class GameTimer
    {
        float elapsedTime;
        float totalTime;
        bool start;

        public GameTimer(float time)
        {
            totalTime = time;
            elapsedTime = 0;
            start = false;
        }

        public void Update(float deltaTime)
        {
            if (!start)
                return;

            elapsedTime += deltaTime;
            if (elapsedTime > totalTime)
            {
                elapsedTime = totalTime;
            }
        }

        public bool TimeOut
        {
            get { return elapsedTime >= totalTime; }
        }

        public void Start()
        {
            start = true;
        }

        public void Stop()
        {
            start = false;
        }

        public void Reset()
        {
            elapsedTime = 0;
            start = false;
        }

        public void Reset(float time)
        {
            totalTime = time;
            elapsedTime = 0;
            start = false;
        }
    }
}
